package com.service.socket;

import java.io.*;
import java.net.Socket;

/**
 * @program: sch-diy-parent
 * @description:
 * @author: sch
 * @create: 2021-01-16 21:14
 **/
public class ClientSocketMy {
    public static void main(String[] args) throws IOException {
        //初始化一个socket
        Socket socket = new Socket("127.0.0.1", 9999);

        //通过socket获取字符流
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
        //通过标准输入注获取字符流
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in, "utf-8"));
        
        while (true) {
            String line = br.readLine();
            bw.write(line);
            bw.write("\n");
            bw.flush();
        }


    }
}
